import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;


@WebServlet("/postParameter")
public class GetBodyFormParameterServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 约定前端发这样的请求：
        // Post /postParameter
        // Content-Type: x-www-form-urlencoded
        //
        // useName=llt&passWord=2569

        // 拿到 body 中的值
        String useName = req.getParameter("useName");
        String passWord = req.getParameter("passWord");

        // 打印
        System.out.println("useName=" + useName);
        System.out.println("passWord=" + passWord);

        resp.getWriter().write("OK!");

    }
}
